<link href="/static/public/layer/src/css/layui.css" rel="stylesheet">
<link href="/static/public/css/style.css" rel="stylesheet">
<script type="text/javascript" src="/static/manage/js/jquery-1.7.2.min.js"></script>
<script src="/static/public/layer/src/layui.js"></script>
	<!-- content starts -->
	<blockquote class="layui-elem-quote"><{$action}></blockquote>

	<fieldset class="layui-elem-field">
        <legend>筛选</legend>
        <div class="layui-field-box">
            <form class="layui-form layui-form-pane1" method="post" action="<{$current_url}>">
                <div class="layui-form-item">
                    <div class="layui-inline">
                        <select name="type" id="type" class="text">
							<option value="0" <{if isset($conditions) AND $conditions.type == 0}>selected<{/if}>>所有题型</option>
							<option value="1" <{if isset($conditions) AND $conditions.type == 1}>selected<{/if}>>单选题</option>
							<option value="2" <{if isset($conditions) AND $conditions.type == 2}>selected<{/if}>>多选题</option>
							<option value="3" <{if isset($conditions) AND $conditions.type == 3}>selected<{/if}>>判断题</option>
							<option value="4" <{if isset($conditions) AND $conditions.type == 4}>selected<{/if}>>计算分析题</option>
							<option value="5" <{if isset($conditions) AND $conditions.type == 5}>selected<{/if}>>填空题</option>
							<option value="6" <{if isset($conditions) AND $conditions.type == 6}>selected<{/if}>>计算题</option>
							<option value="7" <{if isset($conditions) AND $conditions.type == 7}>selected<{/if}>>不定向选择题</option>
							<option value="8" <{if isset($conditions) AND $conditions.type == 8}>selected<{/if}>>名词解释</option>
							<option value="9" <{if isset($conditions) AND $conditions.type == 9}>selected<{/if}>>简答题</option>
						</select>
                    </div>

                    <div class="layui-inline">
                        <input type="text" name="subject_text" id="subject_text" placeholder="题目内容" value="" class="layui-input">
                    </div>

                    <div class="layui-inline">
                        <button type="submit" class="layui-btn">搜索</button>
                    </div>
                </div>
            </form>
        </div>
    </fieldset>
		
	<div class="u_table_list table003 m-t20 line-all">
		<table class="layui-table" lay-even lay-skin="row">
		  	<thead>
			  	<tr>
				  	<th>序号</th>
				  	<th>题干</th>
				  	<th>题型</th>
			  	</tr>
		  	</thead>   
		  	<tbody>
		  	<{foreach from=$topic_list item=item}>
			  	<tr>
			  		<td class="center">
						<input type="checkbox" topic_type="<{$item['type']}>" class="ids" name="ids[]" value="<{$item['id']}>" title="<{$item['id']}>">
						<{$item['id']}>
			  		</td>
			  		<td class="center" title=""><{$item['subject_text']}></td>
			  		<td class="center"><{if $item['type'] == 1}>单选题<{elseif $item['type'] == 2}>多选题<{elseif $item['type'] == 3}>判断题<{elseif $item['type'] == 4}><{elseif $item['type'] == 5}>填空题<{elseif $item['type'] == 6}>计算题计算分析题<{elseif $item['type'] == 7}>不定向选择题<{elseif $item['type'] == 8}>名词解释<{elseif $item['type'] == 9}>简答题<{/if}></td>
			  	</tr>
		  	<{/foreach}>
		  	<{if $topic_list|count eq 0}>
		  		<tr>
			  		<td class="center" style=" height:120px; text-align:center;line-height:120px;" colspan="8">
						赞无数据！
					</td>
			  	</tr>
		  	<{/if}>
	  		</tbody>
	  	</table>
  	</div>
  	<div class="layui-box layui-laypage layui-laypage-default">
		<{$pagination}>
	</div>
<{include file="public_html/footer.html"}>
<script>
		$(function(){
			if($(window.parent.document).find(".selected_topic").length > 0)
			$(window.parent.document).find(".selected_topic").each(function (index, obj){
				$("input[title='"+$(obj).val()+"']").attr("checked", true)
			});
			var ifm= parent.document.getElementById("topic_list_box");   
		    var subWeb = parent.document.frames ? parent.document.frames["topic_list_box"].document : ifm.contentDocument;
		    console.log(subWeb.body.scrollHeight)
		    console.log(subWeb.body.scrollWidth)
		    if(ifm != null && subWeb != null) {
		       ifm.height = subWeb.body.scrollHeight;
		       ifm.width = subWeb.body.scrollWidth;
		    }
		})

		layui.use(['form', 'jquery'], function(){
    			var form = layui.form(),$ = layui.jquery;
				$(".ids").click(function(){
					var _this = $(this);
					$(window.parent.document).find(".type_" + _this.attr("topic_type")).each(function (index,obj){
						if(_this.is(':checked')){
							if($(obj).hasClass('selected') == false){
								$(obj).addClass('selected');
								$(obj).next().addClass('layui-form-checked');
								$(obj).next().removeClass('layui-checkbox-disbaled');
								var input = "<input type='hidden' class='selected_topic' name='topic["+_this.val()+"]' value='"+_this.val()+"'>";
								$(window.parent.document).find("#type_" + _this.attr("topic_type")).append(input);
								return false;
							}
						}else{
							if($(obj).hasClass('selected')){
								$(obj).removeClass('selected');
								$(obj).next().addClass('layui-checkbox-disbaled');
								$(obj).next().removeClass('layui-form-checked');
								form.render('checkbox');
								$(window.parent.document).find("input[name='topic["+_this.val()+"]']").remove();
								return false;
							}
						}
					});
					// $(window.parent.document).find("#topic_list").html($(this).val());
				})
			});
	</script>